<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function fun(a = 2, b = 2) {
            console.log(a,b);
        }
        fun('', 0)

        // 解构赋值 的默认参数
        function fn([a, b = 2]) {
            console.log(a,b);
        }
        // fn('sdf');
        fn([1,9]);// 1 9

        function fun1(a , b) {
            // a = a || 1;
            // b = b || 2;
            typeof a === 'undefined' ? a = 1 : a;
            typeof b === 'undefined' ? b = 1 : b;
            console.log(a, b)
        }
        fun1('', 0); //此时上面的写法打印不出来
        // fun1();

        // 短路运算符
        function fun2(cb) {
            // if(cb) {
            //     cb();
            // }
            cb && cb();
        }
        fun2(function() {
            console.log('ssss');
        });
    </script>
</body>
</html>